
<div id="center_tieude">
    <img src="../../Picture/admin.ico"/>
    <h3>Danh Sách Tin Tức</h3>        
</div> <!--end id center_tieude-->

<div id="timkiem_them">
<form action="" method="post">
    <select name="timkiem_tintuc">
        <option value="mota">Tìm theo mô tả</option>
        <option value="active">Tìm theo Active</option>
    </select>
    <label style="float:left; margin:10px;">Từ khóa:</label>
    <input style="float:left; margin:10px;" type="search" name="key" value=""/>
    <input style="float:left; margin:10px;" type="submit" name="timkiem" value="Tìm Kiếm"/>
</form>
</div><!--end id timkiem_them-->
<table border="1px" cellspacing="0px" width="700px">
  <tr>
      <th>
         ID tin tức
      </th>
      <th>
          Mô tả
      </th>
      <th>
          Nội dung
      </th>
      <th>
          Hình Ảnh
      </th>
      <th>
          Active
      </th>
      <th colspan="2">
          <a href="admin.php?obj=tintuc&act=ad"><img title="Thêm tin tức" alt="Thêm tin tức" src="../../Picture/ad.png"/></a>
      </th>
  </tr>
  
   <?php
	  		if(isset($_GET['trang']))
			{
				$page=$_GET['trang'];
				$arr=tintuc::GetAllFull($page,7);
				for($i=0;$i<count($arr);$i++)     
				{    
				?>  	
					<tr>
                          <td style="width:28px;"> 
                              <?php echo $arr[$i]->idTinTuc;?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->MoTa;?>
                          </td>
                          <td style="width:424px;">
                              <?php echo $arr[$i]->NoiDung;?>
                          </td>
                          <td style="width:28px;">
                               <img src="<?php echo '../../'.$arr[$i]->HinhAnh;?>" style="width:57px; height:50px;"/>
                          </td>
                          <td style="width:59px;">
                              <?php
                                if($arr[$i]->Active==1)
                                    echo "Active";
                                else
                                    echo "Banned";
                               ?>
                          </td>
                          <td>
                              <a href="admin.php?obj=tintuc&act=update&id=<?php echo $arr[$i]->idTinTuc;?>"><img title="Sửa tin tức" alt="Sửa tin tức này" src="../../Picture/update.png"/></a>
                          </td>
                          <td>
                              <a href="admin.php?obj=tintuc&act=delete&id=<?php echo $arr[$i]->idTinTuc;?>"><img title="Xóa tin tức" alt="Xóa tin tức này" src="../../Picture/del.png"/></a>
                          </td>
                      </tr>
     <?php
          		}
			}
			else
			{
				$page=1;
				$arr=tintuc::GetAllFull($page,7);
				for($i=0;$i<count($arr);$i++)     
				{    
				?>  	
					                           <td style="width:28px;"> 
                              <?php echo $arr[$i]->idTinTuc;?>
                          </td>
                          <td>
                              <?php echo $arr[$i]->MoTa;?>
                          </td>
                          <td style="width:424px;">
                              <?php echo $arr[$i]->NoiDung;?>
                          </td>
                          <td style="width:28px;">
                               <img src="<?php echo '../../'.$arr[$i]->HinhAnh;?>" style="width:57px; height:50px;"/>
                          </td>
                          <td style="width:59px;">
                              <?php
                                if($arr[$i]->Active==1)
                                    echo "Active";
                                else
                                    echo "Banned";
                               ?>
                          </td>
                          <td>
                              <a href="admin.php?obj=tintuc&act=update&id=<?php echo $arr[$i]->idTinTuc;?>"><img title="Sửa tin tức" alt="Sửa tin tức này" src="../../Picture/update.png"/></a>
                          </td>
                          <td>
                              <a href="admin.php?obj=tintuc&act=delete&id=<?php echo $arr[$i]->idTinTuc;?>"><img title="Xóa tin tức" alt="Xóa tin tức này" src="../../Picture/del.png"/></a>
                          </td>
                      </tr>

     <?php
          		}
			}		
      ?>

</table><!--end class danhmuc-->
<div id="trang">
	<?php
		if(!isset($_GET["trang"]))
			$_GET["trang"]=1;
		if(isset($_GET["obj"])&&$_GET["obj"]=='tintuc')
		{
		$a = tintuc::CountTinTucFull();
		$sotrang = ceil($a/7);
		$hientai = $_GET["trang"];
			for ($page = 1;(int)$page<=$sotrang;$page++ )
			{
				if($hientai != $page)
				{ echo "
					<a href='admin.php?obj=tintuc&trang=$page'>$page</a>";
				}
				else
				{
					echo "<b>".$page."</b>";
				}
			}
		}
		
?>
</div>
 
</table><!--end class danhmuc-->